package com.force.api.connector;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.force.abril.api.InvalidFieldFaultException;
import com.force.abril.api.InvalidIdFaultException;
import com.force.abril.api.InvalidQueryLocatorFaultException;
import com.force.abril.api.InvalidSObjectFaultException;
import com.force.abril.api.MalformedQueryFaultException;
import com.force.abril.api.QueryResult;
import com.force.abril.api.UnexpectedErrorFaultException;

@Service
public class SalesForceQueryService {

	@Autowired
	private SalesForceService salesForceService;

	public QueryResult searchFor(String query) {
		QueryResult result = null;
		try {
			result = salesForceService.getSoapApi().query(query);
		} catch (InvalidFieldFaultException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvalidIdFaultException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvalidQueryLocatorFaultException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvalidSObjectFaultException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (MalformedQueryFaultException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (UnexpectedErrorFaultException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}

}
